package c.d.a.a.i;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.RectF;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;
import c.d.a.a.a.a;
import c.d.a.a.c.j;
import c.d.a.a.c.k;
import c.d.a.a.e.b;
import c.d.a.a.j.d;
import c.d.a.a.j.e;
import c.d.a.a.j.g;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.data.PieEntry;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Objects;

/* compiled from: PieChartRenderer */
public class h extends c {
    public PieChart f;
    public Paint g;
    public Paint h;
    public Paint i;
    public TextPaint j;
    public Paint k;
    public StaticLayout l;
    public CharSequence m;
    public RectF n = new RectF();
    public RectF[] o = new RectF[]{new RectF(), new RectF(), new RectF()};
    public WeakReference<Bitmap> p;
    public Canvas q;
    public Path r = new Path();
    public RectF s = new RectF();
    public Path t = new Path();
    public Path u = new Path();
    public RectF v = new RectF();

    public h(PieChart pieChart, a aVar, c.d.a.a.j.h hVar) {
        super(aVar, hVar);
        this.f = pieChart;
        Paint paint = new Paint(1);
        this.g = paint;
        paint.setColor(-1);
        this.g.setStyle(Style.FILL);
        paint = new Paint(1);
        this.h = paint;
        paint.setColor(-1);
        this.h.setStyle(Style.FILL);
        this.h.setAlpha(105);
        TextPaint textPaint = new TextPaint(1);
        this.j = textPaint;
        textPaint.setColor(-16777216);
        this.j.setTextSize(g.d(12.0f));
        this.e.setTextSize(g.d(13.0f));
        this.e.setColor(-1);
        this.e.setTextAlign(Align.CENTER);
        paint = new Paint(1);
        this.k = paint;
        paint.setColor(-1);
        this.k.setTextAlign(Align.CENTER);
        this.k.setTextSize(g.d(13.0f));
        paint = new Paint(1);
        this.i = paint;
        paint.setStyle(Style.STROKE);
    }

    /* JADX WARNING: Removed duplicated region for block: B:69:0x0175  */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x0172  */
    /* JADX WARNING: Removed duplicated region for block: B:73:0x018d  */
    /* JADX WARNING: Removed duplicated region for block: B:72:0x0189  */
    /* JADX WARNING: Removed duplicated region for block: B:77:0x01c9  */
    /* JADX WARNING: Removed duplicated region for block: B:76:0x0198  */
    /* JADX WARNING: Removed duplicated region for block: B:84:0x020d  */
    /* JADX WARNING: Removed duplicated region for block: B:115:0x0314  */
    /* JADX WARNING: Removed duplicated region for block: B:88:0x0230  */
    /* JADX WARNING: Removed duplicated region for block: B:121:0x036b  */
    /* JADX WARNING: Removed duplicated region for block: B:118:0x032a  */
    public void b(android.graphics.Canvas r37) {
        /*
        r36 = this;
        r8 = r36;
        r0 = r8.a;
        r1 = r0.c;
        r1 = (int) r1;
        r0 = r0.d;
        r0 = (int) r0;
        r2 = r8.p;
        if (r2 != 0) goto L_0x0010;
    L_0x000e:
        r2 = 0;
        goto L_0x0016;
    L_0x0010:
        r2 = r2.get();
        r2 = (android.graphics.Bitmap) r2;
    L_0x0016:
        if (r2 == 0) goto L_0x0024;
    L_0x0018:
        r3 = r2.getWidth();
        if (r3 != r1) goto L_0x0024;
    L_0x001e:
        r3 = r2.getHeight();
        if (r3 == r0) goto L_0x003c;
    L_0x0024:
        if (r1 <= 0) goto L_0x03a8;
    L_0x0026:
        if (r0 <= 0) goto L_0x03a8;
    L_0x0028:
        r2 = android.graphics.Bitmap.Config.ARGB_4444;
        r2 = android.graphics.Bitmap.createBitmap(r1, r0, r2);
        r0 = new java.lang.ref.WeakReference;
        r0.<init>(r2);
        r8.p = r0;
        r0 = new android.graphics.Canvas;
        r0.<init>(r2);
        r8.q = r0;
    L_0x003c:
        r9 = 0;
        r2.eraseColor(r9);
        r0 = r8.f;
        r0 = r0.getData();
        r0 = (c.d.a.a.c.j) r0;
        r0 = r0.i;
        r10 = r0.iterator();
    L_0x004e:
        r0 = r10.hasNext();
        if (r0 == 0) goto L_0x03a8;
    L_0x0054:
        r0 = r10.next();
        r11 = r0;
        r11 = (c.d.a.a.f.b.h) r11;
        r0 = r11.isVisible();
        if (r0 == 0) goto L_0x03a1;
    L_0x0061:
        r0 = r11.i0();
        if (r0 <= 0) goto L_0x03a1;
    L_0x0067:
        r0 = r8.f;
        r12 = r0.getRotationAngle();
        r0 = r8.b;
        java.util.Objects.requireNonNull(r0);
        r0 = r8.b;
        java.util.Objects.requireNonNull(r0);
        r0 = r8.f;
        r13 = r0.getCircleBox();
        r14 = r11.i0();
        r0 = r8.f;
        r15 = r0.getDrawAngles();
        r0 = r8.f;
        r7 = r0.getCenterCircleBox();
        r0 = r8.f;
        r6 = r0.getRadius();
        r0 = r8.f;
        r1 = r0.O;
        r5 = 1;
        if (r1 == 0) goto L_0x00a1;
    L_0x009a:
        r1 = r0.P;
        if (r1 != 0) goto L_0x00a1;
    L_0x009e:
        r16 = 1;
        goto L_0x00a3;
    L_0x00a1:
        r16 = 0;
    L_0x00a3:
        r1 = 1120403456; // 0x42c80000 float:100.0 double:5.53552857E-315;
        r17 = 0;
        if (r16 == 0) goto L_0x00b2;
    L_0x00a9:
        r0 = r0.getHoleRadius();
        r0 = r0 / r1;
        r0 = r0 * r6;
        r4 = r0;
        goto L_0x00b3;
    L_0x00b2:
        r4 = 0;
    L_0x00b3:
        r0 = r8.f;
        r0 = r0.getHoleRadius();
        r0 = r0 * r6;
        r0 = r0 / r1;
        r0 = r6 - r0;
        r18 = 1073741824; // 0x40000000 float:2.0 double:5.304989477E-315;
        r19 = r0 / r18;
        r3 = new android.graphics.RectF;
        r3.<init>();
        if (r16 == 0) goto L_0x00d2;
    L_0x00c9:
        r0 = r8.f;
        r0 = r0.R;
        if (r0 == 0) goto L_0x00d2;
    L_0x00cf:
        r20 = 1;
        goto L_0x00d4;
    L_0x00d2:
        r20 = 0;
    L_0x00d4:
        r0 = 0;
        r2 = 0;
    L_0x00d6:
        if (r0 >= r14) goto L_0x00ef;
    L_0x00d8:
        r1 = r11.q0(r0);
        r1 = (com.github.mikephil.charting.data.PieEntry) r1;
        r1 = r1.a;
        r1 = java.lang.Math.abs(r1);
        r21 = c.d.a.a.j.g.d;
        r1 = (r1 > r21 ? 1 : (r1 == r21 ? 0 : -1));
        if (r1 <= 0) goto L_0x00ec;
    L_0x00ea:
        r2 = r2 + 1;
    L_0x00ec:
        r0 = r0 + 1;
        goto L_0x00d6;
    L_0x00ef:
        if (r2 > r5) goto L_0x00f4;
    L_0x00f1:
        r21 = 0;
        goto L_0x00fa;
    L_0x00f4:
        r0 = r8.i(r11);
        r21 = r0;
    L_0x00fa:
        r1 = 0;
        r22 = 0;
    L_0x00fd:
        if (r1 >= r14) goto L_0x0398;
    L_0x00ff:
        r23 = r15[r1];
        r0 = r11.q0(r1);
        r0 = r0.a();
        r0 = java.lang.Math.abs(r0);
        r24 = c.d.a.a.j.g.d;
        r25 = 1065353216; // 0x3f800000 float:1.0 double:5.263544247E-315;
        r0 = (r0 > r24 ? 1 : (r0 == r24 ? 0 : -1));
        if (r0 > 0) goto L_0x0116;
    L_0x0115:
        goto L_0x0139;
    L_0x0116:
        r0 = r8.f;
        r24 = r0.l();
        if (r24 != 0) goto L_0x011f;
    L_0x011e:
        goto L_0x0134;
    L_0x011f:
        r5 = r0.A;
        r26 = r0;
        r0 = r5.length;
        if (r9 >= r0) goto L_0x0134;
    L_0x0126:
        r0 = r5[r9];
        r0 = r0.a;
        r0 = (int) r0;
        if (r0 != r1) goto L_0x012f;
    L_0x012d:
        r0 = 1;
        goto L_0x0135;
    L_0x012f:
        r9 = r9 + 1;
        r0 = r26;
        goto L_0x011f;
    L_0x0134:
        r0 = 0;
    L_0x0135:
        if (r0 == 0) goto L_0x0156;
    L_0x0137:
        if (r20 != 0) goto L_0x0156;
    L_0x0139:
        r23 = r23 * r25;
        r23 = r23 + r22;
        r31 = r1;
        r24 = r6;
        r9 = r7;
        r27 = r10;
        r29 = r11;
        r34 = r12;
        r30 = r13;
        r32 = r14;
        r33 = r15;
        r22 = r23;
        r13 = 1;
        r15 = r2;
        r14 = r3;
        r12 = r4;
        goto L_0x0380;
    L_0x0156:
        r9 = 1127481344; // 0x43340000 float:180.0 double:5.570497984E-315;
        r0 = (r21 > r17 ? 1 : (r21 == r17 ? 0 : -1));
        if (r0 <= 0) goto L_0x0162;
    L_0x015c:
        r0 = (r23 > r9 ? 1 : (r23 == r9 ? 0 : -1));
        if (r0 > 0) goto L_0x0162;
    L_0x0160:
        r0 = 1;
        goto L_0x0163;
    L_0x0162:
        r0 = 0;
    L_0x0163:
        r5 = r8.c;
        r9 = r11.A0(r1);
        r5.setColor(r9);
        r9 = 1016003125; // 0x3c8efa35 float:0.017453292 double:5.0197224E-315;
        r5 = 1;
        if (r2 != r5) goto L_0x0175;
    L_0x0172:
        r24 = 0;
        goto L_0x0179;
    L_0x0175:
        r24 = r6 * r9;
        r24 = r21 / r24;
    L_0x0179:
        r27 = r24 / r18;
        r27 = r27 + r22;
        r27 = r27 * r25;
        r9 = r27 + r12;
        r24 = r23 - r24;
        r24 = r24 * r25;
        r27 = (r24 > r17 ? 1 : (r24 == r17 ? 0 : -1));
        if (r27 >= 0) goto L_0x018d;
    L_0x0189:
        r27 = r10;
        r10 = 0;
        goto L_0x0191;
    L_0x018d:
        r27 = r10;
        r10 = r24;
    L_0x0191:
        r5 = r8.r;
        r5.reset();
        if (r20 == 0) goto L_0x01c9;
    L_0x0198:
        r5 = r7.b;
        r29 = r6 - r19;
        r30 = r1;
        r28 = 1016003125; // 0x3c8efa35 float:0.017453292 double:5.0197224E-315;
        r1 = r9 * r28;
        r31 = r2;
        r1 = (double) r1;
        r32 = r14;
        r33 = r15;
        r14 = java.lang.Math.cos(r1);
        r14 = (float) r14;
        r14 = r14 * r29;
        r14 = r14 + r5;
        r5 = r7.c;
        r1 = java.lang.Math.sin(r1);
        r1 = (float) r1;
        r29 = r29 * r1;
        r29 = r29 + r5;
        r1 = r14 - r19;
        r2 = r29 - r19;
        r14 = r14 + r19;
        r5 = r29 + r19;
        r3.set(r1, r2, r14, r5);
        goto L_0x01d1;
    L_0x01c9:
        r30 = r1;
        r31 = r2;
        r32 = r14;
        r33 = r15;
    L_0x01d1:
        r1 = r7.b;
        r2 = 1016003125; // 0x3c8efa35 float:0.017453292 double:5.0197224E-315;
        r5 = r9 * r2;
        r14 = (double) r5;
        r29 = r11;
        r34 = r12;
        r11 = java.lang.Math.cos(r14);
        r2 = (float) r11;
        r2 = r2 * r6;
        r5 = r2 + r1;
        r1 = r7.c;
        r11 = java.lang.Math.sin(r14);
        r2 = (float) r11;
        r2 = r2 * r6;
        r11 = r2 + r1;
        r12 = 1135869952; // 0x43b40000 float:360.0 double:5.611943214E-315;
        r14 = (r10 > r12 ? 1 : (r10 == r12 ? 0 : -1));
        if (r14 < 0) goto L_0x020b;
    L_0x01f7:
        r1 = r10 % r12;
        r2 = c.d.a.a.j.g.d;
        r1 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
        if (r1 > 0) goto L_0x020b;
    L_0x01ff:
        r1 = r8.r;
        r2 = r7.b;
        r15 = r7.c;
        r12 = android.graphics.Path.Direction.CW;
        r1.addCircle(r2, r15, r6, r12);
        goto L_0x021d;
    L_0x020b:
        if (r20 == 0) goto L_0x0218;
    L_0x020d:
        r1 = r8.r;
        r2 = 1127481344; // 0x43340000 float:180.0 double:5.570497984E-315;
        r12 = r9 + r2;
        r2 = -1020002304; // 0xffffffffc3340000 float:-180.0 double:NaN;
        r1.arcTo(r3, r12, r2);
    L_0x0218:
        r1 = r8.r;
        r1.arcTo(r13, r9, r10);
    L_0x021d:
        r1 = r8.s;
        r2 = r7.b;
        r12 = r2 - r4;
        r15 = r7.c;
        r35 = r3;
        r3 = r15 - r4;
        r2 = r2 + r4;
        r15 = r15 + r4;
        r1.set(r12, r3, r2, r15);
        if (r16 == 0) goto L_0x0314;
    L_0x0230:
        r1 = (r4 > r17 ? 1 : (r4 == r17 ? 0 : -1));
        if (r1 > 0) goto L_0x0247;
    L_0x0234:
        if (r0 == 0) goto L_0x0237;
    L_0x0236:
        goto L_0x0247;
    L_0x0237:
        r12 = r4;
        r24 = r6;
        r15 = r31;
        r14 = r35;
        r1 = 1135869952; // 0x43b40000 float:360.0 double:5.611943214E-315;
        r31 = r30;
        r30 = r13;
        r13 = 1;
        goto L_0x0322;
    L_0x0247:
        if (r0 == 0) goto L_0x0270;
    L_0x0249:
        r3 = r23 * r25;
        r0 = r36;
        r12 = r30;
        r1 = r7;
        r15 = r31;
        r2 = r6;
        r30 = r13;
        r13 = r35;
        r31 = r12;
        r12 = r4;
        r4 = r5;
        r13 = 1;
        r5 = r11;
        r24 = r6;
        r6 = r9;
        r9 = r7;
        r7 = r10;
        r0 = r0.h(r1, r2, r3, r4, r5, r6, r7);
        r1 = (r0 > r17 ? 1 : (r0 == r17 ? 0 : -1));
        if (r1 >= 0) goto L_0x026b;
    L_0x026a:
        r0 = -r0;
    L_0x026b:
        r4 = java.lang.Math.max(r12, r0);
        goto L_0x027b;
    L_0x0270:
        r12 = r4;
        r24 = r6;
        r9 = r7;
        r15 = r31;
        r31 = r30;
        r30 = r13;
        r13 = 1;
    L_0x027b:
        if (r15 == r13) goto L_0x028a;
    L_0x027d:
        r0 = (r4 > r17 ? 1 : (r4 == r17 ? 0 : -1));
        if (r0 != 0) goto L_0x0282;
    L_0x0281:
        goto L_0x028a;
    L_0x0282:
        r0 = 1016003125; // 0x3c8efa35 float:0.017453292 double:5.0197224E-315;
        r1 = r4 * r0;
        r0 = r21 / r1;
        goto L_0x028b;
    L_0x028a:
        r0 = 0;
    L_0x028b:
        r1 = r0 / r18;
        r1 = r1 + r22;
        r1 = r1 * r25;
        r1 = r1 + r34;
        r0 = r23 - r0;
        r0 = r0 * r25;
        r2 = (r0 > r17 ? 1 : (r0 == r17 ? 0 : -1));
        if (r2 >= 0) goto L_0x029c;
    L_0x029b:
        r0 = 0;
    L_0x029c:
        r1 = r1 + r0;
        if (r14 < 0) goto L_0x02b7;
    L_0x029f:
        r2 = 1135869952; // 0x43b40000 float:360.0 double:5.611943214E-315;
        r10 = r10 % r2;
        r2 = c.d.a.a.j.g.d;
        r2 = (r10 > r2 ? 1 : (r10 == r2 ? 0 : -1));
        if (r2 > 0) goto L_0x02b7;
    L_0x02a8:
        r0 = r8.r;
        r1 = r9.b;
        r2 = r9.c;
        r3 = android.graphics.Path.Direction.CCW;
        r0.addCircle(r1, r2, r4, r3);
        r14 = r35;
        goto L_0x036c;
    L_0x02b7:
        if (r20 == 0) goto L_0x02ea;
    L_0x02b9:
        r2 = r9.b;
        r6 = r24 - r19;
        r3 = 1016003125; // 0x3c8efa35 float:0.017453292 double:5.0197224E-315;
        r3 = r3 * r1;
        r3 = (double) r3;
        r10 = java.lang.Math.cos(r3);
        r5 = (float) r10;
        r5 = r5 * r6;
        r5 = r5 + r2;
        r2 = r9.c;
        r3 = java.lang.Math.sin(r3);
        r3 = (float) r3;
        r6 = r6 * r3;
        r6 = r6 + r2;
        r2 = r5 - r19;
        r3 = r6 - r19;
        r5 = r5 + r19;
        r6 = r6 + r19;
        r14 = r35;
        r14.set(r2, r3, r5, r6);
        r2 = r8.r;
        r3 = 1127481344; // 0x43340000 float:180.0 double:5.570497984E-315;
        r2.arcTo(r14, r1, r3);
        goto L_0x030b;
    L_0x02ea:
        r14 = r35;
        r2 = r8.r;
        r3 = r9.b;
        r5 = 1016003125; // 0x3c8efa35 float:0.017453292 double:5.0197224E-315;
        r5 = r5 * r1;
        r5 = (double) r5;
        r10 = java.lang.Math.cos(r5);
        r7 = (float) r10;
        r7 = r7 * r4;
        r7 = r7 + r3;
        r3 = r9.c;
        r5 = java.lang.Math.sin(r5);
        r5 = (float) r5;
        r4 = r4 * r5;
        r4 = r4 + r3;
        r2.lineTo(r7, r4);
    L_0x030b:
        r2 = r8.r;
        r3 = r8.s;
        r0 = -r0;
        r2.arcTo(r3, r1, r0);
        goto L_0x036c;
    L_0x0314:
        r12 = r4;
        r24 = r6;
        r15 = r31;
        r14 = r35;
        r31 = r30;
        r30 = r13;
        r13 = 1;
        r1 = 1135869952; // 0x43b40000 float:360.0 double:5.611943214E-315;
    L_0x0322:
        r1 = r10 % r1;
        r2 = c.d.a.a.j.g.d;
        r1 = (r1 > r2 ? 1 : (r1 == r2 ? 0 : -1));
        if (r1 <= 0) goto L_0x036b;
    L_0x032a:
        if (r0 == 0) goto L_0x0360;
    L_0x032c:
        r0 = r10 / r18;
        r26 = r0 + r9;
        r3 = r23 * r25;
        r0 = r36;
        r1 = r7;
        r2 = r24;
        r4 = r5;
        r5 = r11;
        r6 = r9;
        r9 = r7;
        r7 = r10;
        r0 = r0.h(r1, r2, r3, r4, r5, r6, r7);
        r1 = r9.b;
        r2 = 1016003125; // 0x3c8efa35 float:0.017453292 double:5.0197224E-315;
        r2 = r2 * r26;
        r2 = (double) r2;
        r4 = java.lang.Math.cos(r2);
        r4 = (float) r4;
        r4 = r4 * r0;
        r4 = r4 + r1;
        r1 = r9.c;
        r2 = java.lang.Math.sin(r2);
        r2 = (float) r2;
        r0 = r0 * r2;
        r0 = r0 + r1;
        r1 = r8.r;
        r1.lineTo(r4, r0);
        goto L_0x036c;
    L_0x0360:
        r9 = r7;
        r0 = r8.r;
        r1 = r9.b;
        r2 = r9.c;
        r0.lineTo(r1, r2);
        goto L_0x036c;
    L_0x036b:
        r9 = r7;
    L_0x036c:
        r0 = r8.r;
        r0.close();
        r0 = r8.q;
        r1 = r8.r;
        r2 = r8.c;
        r0.drawPath(r1, r2);
        r23 = r23 * r25;
        r23 = r23 + r22;
        r22 = r23;
    L_0x0380:
        r1 = r31 + 1;
        r7 = r9;
        r4 = r12;
        r3 = r14;
        r2 = r15;
        r6 = r24;
        r10 = r27;
        r11 = r29;
        r13 = r30;
        r14 = r32;
        r15 = r33;
        r12 = r34;
        r5 = 1;
        r9 = 0;
        goto L_0x00fd;
    L_0x0398:
        r9 = r7;
        r27 = r10;
        r0 = c.d.a.a.j.d.d;
        r0.c(r9);
        goto L_0x03a3;
    L_0x03a1:
        r27 = r10;
    L_0x03a3:
        r10 = r27;
        r9 = 0;
        goto L_0x004e;
    L_0x03a8:
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.d.a.a.i.h.b(android.graphics.Canvas):void");
    }

    public void c(Canvas canvas) {
        float transparentCircleRadius;
        Canvas canvas2 = canvas;
        PieChart pieChart = this.f;
        if (pieChart.O && this.q != null) {
            float radius = pieChart.getRadius();
            float holeRadius = (this.f.getHoleRadius() / 100.0f) * radius;
            d centerCircleBox = this.f.getCenterCircleBox();
            if (Color.alpha(this.g.getColor()) > 0) {
                this.q.drawCircle(centerCircleBox.b, centerCircleBox.c, holeRadius, this.g);
            }
            if (Color.alpha(this.h.getColor()) > 0 && this.f.getTransparentCircleRadius() > this.f.getHoleRadius()) {
                int alpha = this.h.getAlpha();
                transparentCircleRadius = (this.f.getTransparentCircleRadius() / 100.0f) * radius;
                Paint paint = this.h;
                float f = (float) alpha;
                Objects.requireNonNull(this.b);
                f *= 1.0f;
                Objects.requireNonNull(this.b);
                paint.setAlpha((int) (f * 1.0f));
                this.t.reset();
                this.t.addCircle(centerCircleBox.b, centerCircleBox.c, transparentCircleRadius, Direction.CW);
                this.t.addCircle(centerCircleBox.b, centerCircleBox.c, holeRadius, Direction.CCW);
                this.q.drawPath(this.t, this.h);
                this.h.setAlpha(alpha);
            }
            d.d.c(centerCircleBox);
        }
        canvas2.drawBitmap((Bitmap) this.p.get(), 0.0f, 0.0f, null);
        CharSequence centerText = this.f.getCenterText();
        pieChart = this.f;
        if (pieChart.W && centerText != null) {
            float radius2;
            RectF rectF;
            d centerCircleBox2 = pieChart.getCenterCircleBox();
            d centerTextOffset = this.f.getCenterTextOffset();
            float f2 = centerCircleBox2.b + centerTextOffset.b;
            transparentCircleRadius = centerCircleBox2.c + centerTextOffset.c;
            PieChart pieChart2 = this.f;
            if (!pieChart2.O || pieChart2.P) {
                radius2 = pieChart2.getRadius();
            } else {
                radius2 = (this.f.getHoleRadius() / 100.0f) * pieChart2.getRadius();
            }
            RectF[] rectFArr = this.o;
            RectF rectF2 = rectFArr[0];
            rectF2.left = f2 - radius2;
            rectF2.top = transparentCircleRadius - radius2;
            rectF2.right = f2 + radius2;
            rectF2.bottom = transparentCircleRadius + radius2;
            RectF rectF3 = rectFArr[1];
            rectF3.set(rectF2);
            f2 = this.f.getCenterTextRadiusPercent() / 100.0f;
            if (((double) f2) > 0.0d) {
                rectF3.inset((rectF3.width() - (rectF3.width() * f2)) / 2.0f, (rectF3.height() - (rectF3.height() * f2)) / 2.0f);
            }
            if (centerText.equals(this.m) && rectF3.equals(this.n)) {
                rectF = rectF3;
            } else {
                this.n.set(rectF3);
                this.m = centerText;
                StaticLayout staticLayout = r5;
                rectF = rectF3;
                StaticLayout staticLayout2 = new StaticLayout(centerText, 0, centerText.length(), this.j, (int) Math.max(Math.ceil((double) this.n.width()), 1.0d), Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
                this.l = staticLayout;
            }
            f2 = (float) this.l.getHeight();
            canvas.save();
            Path path = this.u;
            path.reset();
            path.addOval(rectF2, Direction.CW);
            canvas2.clipPath(path);
            canvas2.translate(rectF.left, ((rectF.height() - f2) / 2.0f) + rectF.top);
            this.l.draw(canvas2);
            canvas.restore();
            d.d.c(centerCircleBox2);
            d.d.c(centerTextOffset);
        }
    }

    public void d(Canvas canvas, b[] bVarArr) {
        b[] bVarArr2 = bVarArr;
        PieChart pieChart = this.f;
        Object obj = (!pieChart.O || pieChart.P) ? null : 1;
        if (obj == null || !pieChart.R) {
            Objects.requireNonNull(this.b);
            Objects.requireNonNull(this.b);
            float rotationAngle = this.f.getRotationAngle();
            float[] drawAngles = this.f.getDrawAngles();
            float[] absoluteAngles = this.f.getAbsoluteAngles();
            e.a centerCircleBox = this.f.getCenterCircleBox();
            float radius = this.f.getRadius();
            float holeRadius = obj != null ? (this.f.getHoleRadius() / 100.0f) * radius : 0.0f;
            RectF rectF = this.v;
            rectF.set(0.0f, 0.0f, 0.0f, 0.0f);
            int i = 0;
            while (i < bVarArr2.length) {
                int i2;
                float[] fArr;
                float[] fArr2;
                float f;
                RectF rectF2;
                e.a aVar;
                Object obj2;
                int i3 = (int) bVarArr2[i].a;
                if (i3 < drawAngles.length) {
                    j jVar = (j) this.f.getData();
                    int i4 = bVarArr2[i].f;
                    Objects.requireNonNull(jVar);
                    c.d.a.a.f.b.d j = i4 == 0 ? jVar.j() : null;
                    if (j != null && j.n0()) {
                        float f2;
                        float f3;
                        float f4;
                        int i5;
                        double d;
                        int i6;
                        float h;
                        i4 = j.i0();
                        int i7 = 0;
                        for (i2 = 0; i2 < i4; i2++) {
                            if (Math.abs(((PieEntry) j.q0(i2)).a) > g.d) {
                                i7++;
                            }
                        }
                        if (i3 == 0) {
                            i4 = 1;
                            f2 = 0.0f;
                        } else {
                            f2 = absoluteAngles[i3 - 1] * 1.0f;
                            i4 = 1;
                        }
                        if (i7 <= i4) {
                            f3 = 0.0f;
                        } else {
                            f3 = j.j();
                        }
                        float f5 = drawAngles[i3];
                        float O = j.O();
                        float f6 = radius + O;
                        int i8 = i;
                        rectF.set(this.f.getCircleBox());
                        O = -O;
                        rectF.inset(O, O);
                        Object obj3 = (f3 <= 0.0f || f5 > 180.0f) ? null : 1;
                        this.c.setColor(j.A0(i3));
                        O = i7 == 1 ? 0.0f : f3 / (radius * 0.017453292f);
                        float f7 = i7 == 1 ? 0.0f : f3 / (f6 * 0.017453292f);
                        float f8 = (((O / 2.0f) + f2) * 1.0f) + rotationAngle;
                        O = (f5 - O) * 1.0f;
                        float f9 = O < 0.0f ? 0.0f : O;
                        float f10 = (((f7 / 2.0f) + f2) * 1.0f) + rotationAngle;
                        O = (f5 - f7) * 1.0f;
                        if (O < 0.0f) {
                            O = 0.0f;
                        }
                        this.r.reset();
                        int i9 = (f9 > 360.0f ? 1 : (f9 == 360.0f ? 0 : -1));
                        if (i9 < 0 || f9 % 360.0f > g.d) {
                            f4 = holeRadius;
                            i5 = i7;
                            double d2 = (double) (f10 * 0.017453292f);
                            fArr = drawAngles;
                            fArr2 = absoluteAngles;
                            this.r.moveTo((((float) Math.cos(d2)) * f6) + centerCircleBox.b, (f6 * ((float) Math.sin(d2))) + centerCircleBox.c);
                            this.r.arcTo(rectF, f10, O);
                        } else {
                            this.r.addCircle(centerCircleBox.b, centerCircleBox.c, f6, Direction.CW);
                            f4 = holeRadius;
                            i5 = i7;
                            fArr = drawAngles;
                            fArr2 = absoluteAngles;
                        }
                        if (obj3 != null) {
                            d = (double) (f8 * 0.017453292f);
                            i2 = i8;
                            f = f4;
                            i6 = i5;
                            rectF2 = rectF;
                            aVar = centerCircleBox;
                            h = h(centerCircleBox, radius, f5 * 1.0f, (((float) Math.cos(d)) * radius) + centerCircleBox.b, (((float) Math.sin(d)) * radius) + centerCircleBox.c, f8, f9);
                        } else {
                            aVar = centerCircleBox;
                            i2 = i8;
                            f = f4;
                            i6 = i5;
                            rectF2 = rectF;
                            h = 0.0f;
                        }
                        RectF rectF3 = this.s;
                        f10 = aVar.b;
                        O = f10 - f;
                        float f11 = aVar.c;
                        rectF3.set(O, f11 - f, f10 + f, f11 + f);
                        if (obj == null || (f <= 0.0f && obj3 == null)) {
                            obj2 = obj;
                            if (f9 % 360.0f > g.d) {
                                if (obj3 != null) {
                                    d = (double) (((f9 / 2.0f) + f8) * 0.017453292f);
                                    this.r.lineTo((((float) Math.cos(d)) * h) + aVar.b, (h * ((float) Math.sin(d))) + aVar.c);
                                } else {
                                    this.r.lineTo(aVar.b, aVar.c);
                                }
                            }
                        } else {
                            if (obj3 != null) {
                                if (h < 0.0f) {
                                    h = -h;
                                }
                                holeRadius = Math.max(f, h);
                            } else {
                                holeRadius = f;
                            }
                            h = (i6 == 1 || holeRadius == 0.0f) ? 0.0f : f3 / (holeRadius * 0.017453292f);
                            f10 = (((h / 2.0f) + f2) * 1.0f) + rotationAngle;
                            h = (f5 - h) * 1.0f;
                            if (h < 0.0f) {
                                h = 0.0f;
                            }
                            f10 += h;
                            if (i9 < 0 || f9 % 360.0f > g.d) {
                                float f12 = f10;
                                double d3 = (double) (f10 * 0.017453292f);
                                obj2 = obj;
                                this.r.lineTo((((float) Math.cos(d3)) * holeRadius) + aVar.b, (holeRadius * ((float) Math.sin(d3))) + aVar.c);
                                this.r.arcTo(this.s, f12, -h);
                            } else {
                                this.r.addCircle(aVar.b, aVar.c, holeRadius, Direction.CCW);
                                obj2 = obj;
                            }
                        }
                        this.r.close();
                        this.q.drawPath(this.r, this.c);
                        i = i2 + 1;
                        bVarArr2 = bVarArr;
                        obj = obj2;
                        centerCircleBox = aVar;
                        holeRadius = f;
                        rectF = rectF2;
                        drawAngles = fArr;
                        absoluteAngles = fArr2;
                    }
                }
                i2 = i;
                rectF2 = rectF;
                obj2 = obj;
                fArr = drawAngles;
                fArr2 = absoluteAngles;
                f = holeRadius;
                aVar = centerCircleBox;
                i = i2 + 1;
                bVarArr2 = bVarArr;
                obj = obj2;
                centerCircleBox = aVar;
                holeRadius = f;
                rectF = rectF2;
                drawAngles = fArr;
                absoluteAngles = fArr2;
            }
            d.d.c(centerCircleBox);
        }
    }

    public void e(Canvas canvas) {
        float f;
        float f2;
        Canvas canvas2;
        Canvas canvas3 = canvas;
        k.a aVar = k.a.INSIDE_SLICE;
        k.a aVar2 = k.a.OUTSIDE_SLICE;
        e.a centerCircleBox = this.f.getCenterCircleBox();
        float radius = this.f.getRadius();
        float rotationAngle = this.f.getRotationAngle();
        float[] drawAngles = this.f.getDrawAngles();
        float[] absoluteAngles = this.f.getAbsoluteAngles();
        Objects.requireNonNull(this.b);
        Objects.requireNonNull(this.b);
        float holeRadius = (radius - ((this.f.getHoleRadius() * radius) / 100.0f)) / 2.0f;
        float holeRadius2 = this.f.getHoleRadius() / 100.0f;
        float f3 = (radius / 10.0f) * 3.6f;
        PieChart pieChart = this.f;
        if (pieChart.O) {
            f3 = (radius - (radius * holeRadius2)) / 2.0f;
            if (pieChart.P || !pieChart.R) {
                f = f3;
            } else {
                f = f3;
                rotationAngle = (float) ((((double) (holeRadius * 360.0f)) / (((double) radius) * 6.283185307179586d)) + ((double) rotationAngle));
            }
            f2 = rotationAngle;
            f3 = f;
        } else {
            f2 = rotationAngle;
        }
        float f4 = radius - f3;
        c.d.a.a.c.d dVar = (j) pieChart.getData();
        List list = dVar.i;
        float k = dVar.k();
        boolean z = this.f.L;
        canvas.save();
        f = g.d(5.0f);
        int i = 0;
        int i2 = 0;
        while (i2 < list.size()) {
            c.d.a.a.c.d dVar2;
            List list2;
            int i3;
            float f5;
            float f6;
            float[] fArr;
            float[] fArr2;
            boolean z2;
            k.a aVar3;
            k.a aVar4;
            e.a aVar5;
            float f7;
            c.d.a.a.f.b.d dVar3 = (c.d.a.a.f.b.h) list.get(i2);
            boolean V = dVar3.V();
            if (V || z) {
                dVar2 = dVar;
                k.a c = dVar3.c();
                list2 = list;
                k.a v = dVar3.v();
                a(dVar3);
                int i4 = i;
                i3 = i2;
                float d = g.d(4.0f) + ((float) g.a(this.e, "Q"));
                c.d.a.a.d.e h0 = dVar3.h0();
                i = dVar3.i0();
                e.a aVar6 = centerCircleBox;
                float f8 = radius;
                this.i.setColor(dVar3.v0());
                this.i.setStrokeWidth(g.d(dVar3.a()));
                float i5 = i(dVar3);
                e.a c2 = d.c(dVar3.j0());
                f5 = holeRadius2;
                c2.b = g.d(c2.b);
                c2.c = g.d(c2.c);
                int i6 = 0;
                while (i6 < i) {
                    float f9;
                    c.d.a.a.d.e eVar;
                    float f10;
                    String str;
                    c.d.a.a.f.b.d dVar4;
                    k.a aVar7;
                    k.a aVar8;
                    int i7 = i;
                    PieEntry pieEntry = (PieEntry) dVar3.q0(i6);
                    if (i4 == 0) {
                        f9 = 0.0f;
                    } else {
                        f9 = absoluteAngles[i4 - 1] * 1.0f;
                    }
                    f9 = i5;
                    i5 = ((((drawAngles[i4] - ((i5 / (f4 * 0.017453292f)) / 2.0f)) / 2.0f) + f9) * 1.0f) + f2;
                    f6 = f2;
                    if (this.f.Q) {
                        f2 = (pieEntry.a / k) * 100.0f;
                    } else {
                        f2 = pieEntry.a;
                    }
                    String b = h0.b(f2, pieEntry);
                    String str2 = pieEntry.d;
                    fArr = drawAngles;
                    fArr2 = absoluteAngles;
                    double d2 = (double) (i5 * 0.017453292f);
                    rotationAngle = i5;
                    e.a aVar9 = c2;
                    float cos = (float) Math.cos(d2);
                    i5 = (float) Math.sin(d2);
                    Object obj = (z && c == aVar2) ? 1 : null;
                    Object obj2 = (V && v == aVar2) ? 1 : null;
                    Object obj3 = (z && c == aVar) ? 1 : null;
                    Object obj4 = (V && v == aVar) ? 1 : null;
                    if (obj == null && obj2 == null) {
                        eVar = h0;
                        z2 = z;
                        aVar3 = aVar;
                        aVar4 = aVar2;
                        f10 = i5;
                        aVar5 = aVar6;
                        str = str2;
                        dVar4 = dVar3;
                        aVar7 = v;
                        f7 = f8;
                        canvas2 = canvas;
                        aVar8 = c;
                    } else {
                        float f11;
                        float f12;
                        float b2 = dVar3.b();
                        float E = dVar3.E();
                        eVar = h0;
                        f3 = dVar3.T() / 100.0f;
                        z2 = z;
                        if (this.f.O) {
                            f11 = f8 * f5;
                            aVar3 = aVar;
                            f12 = f8;
                            f3 = c.b.a.a.a.a(f12, f11, f3, f11);
                        } else {
                            aVar3 = aVar;
                            f12 = f8;
                            f3 *= f12;
                        }
                        E = dVar3.x() ? (E * f4) * ((float) Math.abs(Math.sin(d2))) : E * f4;
                        f11 = f3 * cos;
                        aVar5 = aVar6;
                        float f13 = aVar5.b;
                        f11 += f13;
                        f3 *= i5;
                        aVar7 = v;
                        float f14 = aVar5.c;
                        f3 += f14;
                        b2 = (b2 + 1.0f) * f4;
                        f13 = (b2 * cos) + f13;
                        float f15 = (b2 * i5) + f14;
                        aVar8 = c;
                        double d3 = ((double) rotationAngle) % 360.0d;
                        if (d3 < 90.0d || d3 > 270.0d) {
                            E = f13 + E;
                            this.e.setTextAlign(Align.LEFT);
                            if (obj != null) {
                                this.k.setTextAlign(Align.LEFT);
                            }
                            f14 = E + f;
                        } else {
                            rotationAngle = f13 - E;
                            this.e.setTextAlign(Align.RIGHT);
                            if (obj != null) {
                                this.k.setTextAlign(Align.RIGHT);
                            }
                            f14 = rotationAngle - f;
                            E = rotationAngle;
                        }
                        float f16 = f14;
                        String str3;
                        if (dVar3.v0() != 1122867) {
                            if (dVar3.L()) {
                                this.i.setColor(dVar3.A0(i6));
                            }
                            str3 = str2;
                            f7 = f12;
                            str = str3;
                            Canvas canvas4 = canvas;
                            aVar4 = aVar2;
                            dVar4 = dVar3;
                            f14 = f15;
                            f10 = i5;
                            i5 = f16;
                            canvas4.drawLine(f11, f3, f13, f14, this.i);
                            canvas4.drawLine(f13, f15, E, f14, this.i);
                        } else {
                            aVar4 = aVar2;
                            f10 = i5;
                            dVar4 = dVar3;
                            i5 = f16;
                            str3 = str2;
                            f7 = f12;
                            str = str3;
                        }
                        if (obj == null || obj2 == null) {
                            canvas2 = canvas;
                            f3 = f15;
                            if (obj != null) {
                                if (i6 < dVar2.e() && str != null) {
                                    canvas2.drawText(str, i5, (d / 2.0f) + f3, this.k);
                                }
                            } else if (obj2 != null) {
                                rotationAngle = (d / 2.0f) + f3;
                                this.e.setColor(dVar4.s(i6));
                                canvas2.drawText(b, i5, rotationAngle, this.e);
                            }
                        } else {
                            this.e.setColor(dVar4.s(i6));
                            canvas2 = canvas;
                            f3 = f15;
                            canvas2.drawText(b, i5, f3, this.e);
                            if (i6 < dVar2.e() && str != null) {
                                canvas2.drawText(str, i5, f3 + d, this.k);
                            }
                        }
                    }
                    if (obj3 != null || obj4 != null) {
                        i5 = (f4 * cos) + aVar5.b;
                        rotationAngle = (f10 * f4) + aVar5.c;
                        this.e.setTextAlign(Align.CENTER);
                        if (obj3 != null && obj4 != null) {
                            this.e.setColor(dVar4.s(i6));
                            canvas2.drawText(b, i5, rotationAngle, this.e);
                            if (i6 < dVar2.e() && str != null) {
                                canvas2.drawText(str, i5, rotationAngle + d, this.k);
                            }
                        } else if (obj3 != null) {
                            if (i6 < dVar2.e() && str != null) {
                                canvas2.drawText(str, i5, (d / 2.0f) + rotationAngle, this.k);
                            }
                        } else if (obj4 != null) {
                            f3 = (d / 2.0f) + rotationAngle;
                            this.e.setColor(dVar4.s(i6));
                            canvas2.drawText(b, i5, f3, this.e);
                        }
                    }
                    i4++;
                    i6++;
                    dVar3 = dVar4;
                    v = aVar7;
                    c = aVar8;
                    i = i7;
                    i5 = f9;
                    f2 = f6;
                    f8 = f7;
                    absoluteAngles = fArr2;
                    c2 = aVar9;
                    aVar2 = aVar4;
                    z = z2;
                    aVar = aVar3;
                    h0 = eVar;
                    aVar6 = aVar5;
                    drawAngles = fArr;
                }
                canvas2 = canvas;
                z2 = z;
                f6 = f2;
                aVar3 = aVar;
                aVar4 = aVar2;
                fArr = drawAngles;
                fArr2 = absoluteAngles;
                aVar5 = aVar6;
                f7 = f8;
                d.d.c(c2);
                i = i4;
            } else {
                canvas2 = canvas;
                i3 = i2;
                z2 = z;
                list2 = list;
                dVar2 = dVar;
                f6 = f2;
                aVar3 = aVar;
                aVar4 = aVar2;
                f7 = radius;
                fArr = drawAngles;
                fArr2 = absoluteAngles;
                f5 = holeRadius2;
                aVar5 = centerCircleBox;
            }
            i2 = i3 + 1;
            centerCircleBox = aVar5;
            dVar = dVar2;
            list = list2;
            holeRadius2 = f5;
            f2 = f6;
            drawAngles = fArr;
            radius = f7;
            absoluteAngles = fArr2;
            aVar2 = aVar4;
            z = z2;
            aVar = aVar3;
        }
        canvas2 = canvas;
        d.d.c(centerCircleBox);
        canvas.restore();
    }

    public void f() {
    }

    public float h(d dVar, float f, float f2, float f3, float f4, float f5, float f6) {
        d dVar2 = dVar;
        float f7 = (f6 / 2.0f) + f5;
        double d = (double) ((f5 + f6) * 0.017453292f);
        float cos = (((float) Math.cos(d)) * f) + dVar2.b;
        float sin = (((float) Math.sin(d)) * f) + dVar2.c;
        double d2 = (double) (f7 * 0.017453292f);
        f7 = (((float) Math.cos(d2)) * f) + dVar2.b;
        float sin2 = (((float) Math.sin(d2)) * f) + dVar2.c;
        return (float) (((double) (f - ((float) (Math.tan(((180.0d - ((double) f2)) / 2.0d) * 0.017453292519943295d) * (Math.sqrt(Math.pow((double) (sin - f4), 2.0d) + Math.pow((double) (cos - f3), 2.0d)) / 2.0d))))) - Math.sqrt(Math.pow((double) (sin2 - ((sin + f4) / 2.0f)), 2.0d) + Math.pow((double) (f7 - ((cos + f3) / 2.0f)), 2.0d)));
    }

    public float i(c.d.a.a.f.b.h hVar) {
        if (!hVar.k0()) {
            return hVar.j();
        }
        float f;
        float j = hVar.j();
        c.d.a.a.j.h hVar2 = this.a;
        if (j / Math.min(hVar2.b.width(), hVar2.b.height()) > (hVar.R() / ((j) this.f.getData()).k()) * 2.0f) {
            f = 0.0f;
        } else {
            f = hVar.j();
        }
        return f;
    }
}
